﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class wangyin_getway : System.Web.UI.Page
{
    public string P_OrderId = "";

    public string channelId
    {
        get { return Request.Form["channelId"]; }
    }

    public string cardId
    {
        get { return Request.Form["cardId"]; }
    }

    public string cardPass
    {
        get { return Request.Form["cardPass"]; }
    }

    public string faceValue
    {
        get { return Request.Form["faceValue"]; }
    }


    public string P_Description
    {
        get { return Request.Form["pd_FrpId"]; }
    }




    protected void Page_Load(object sender, EventArgs e)
    {
        string notify_Url = Domain + "/notify_Url.aspx";
        string result_url = Domain + "/result_url.aspx";

        string P_UserId = Config.UserId;
        P_OrderId = DateTime.Now.ToString("yyyyMMddHHmmssfff");
        string P_CardId = cardId;
        string P_CardPass = cardPass;
        string P_FaceValue = faceValue;
        string P_ChannelId = channelId;
        if (P_Description == "20000")
            P_ChannelId = "21";

        string P_Subject = "Subject";
        string P_Price = faceValue;
        string P_Quantity = "1";
      //  string P_Description = "Description";
        string P_Notic = "Notic";
        string P_Result_URL = result_url;
        string P_Notify_URL = notify_Url;

        string plain = P_UserId + "|" + P_OrderId + "|" + P_CardId + "|" + P_CardPass + "|" + P_FaceValue + "|" + P_ChannelId + "|" + Config.SalfStr;

        string P_PostKey = MD5Util.GetMD5(plain, "gb2312").ToLower();


        string postUrl = Config.BankGateway +
            string.Format(
                "?P_UserId={0}&P_OrderId={1}&P_CardId={2}&P_CardPass={3}&P_FaceValue={4}&P_ChannelId={5}&P_Subject={6}&P_Price={7}&P_Quantity={8}&P_Description={9}&P_Notic={10}&P_Result_URL={11}&P_Notify_URL={12}&P_PostKey={13}"
                , P_UserId
                , P_OrderId
                , P_CardId
                , P_CardPass
                , P_FaceValue
                , P_ChannelId
                , P_Subject
                , P_Price
                , P_Quantity
                , P_Description
                , P_Notic
                , P_Result_URL
                , P_Notify_URL
                , P_PostKey
                );

        Response.Redirect(postUrl);

    }

    public string Domain
    {
        get
        {
            return string.Format("{0}://{1}", Request.Url.Scheme, Request.ServerVariables["http_host"]);
        }
    }

}